#ifndef __GZ_INTERFACE_TIMER_H__
#define __GZ_INTERFACE_TIMER_H__

#include <functional>
#include <memory>

namespace Gazella {

struct ITimerCallbackArg: public std::enable_shared_from_this<ITimerCallbackArg> {
    virtual ~ITimerCallbackArg() = default;
};

typedef std::function<void(std::shared_ptr<ITimerCallbackArg>)> timer_callback_t;

class GzTimer {
public:
    GzTimer();
    ~GzTimer();

    //create a timer
    //return timer_id, timer_id == 0 when error
    static uint32_t create_timer(
        timer_callback_t timer_callback, //timer callback, it will be called by the threadpool
        std::shared_ptr<ITimerCallbackArg> arg, //thread callback user data
        float after,
        float repeat = 0.0,
        bool auto_start = true
    );

    //start timer of timerid
    static void start_timer(uint32_t timer_id);

    //stop timer of timerid
    static void stop_timer(uint32_t timer_id);

    //delete timer of timerid, if sync == true, waiting for timer handler over 
    static bool delete_timer(uint32_t timer_id, bool sync = true);
};
} // namespace Gazella
#endif
